export default [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/center',
    component:()=>import('../pages/center/index'),
    name:'center',
    redirect: '/center/myOrder',
    children:[
      {
        path:'myOrder',
        component:()=>import('../pages/center/myOrder/index')
      },
      {
        path: 'groupOrder',
        component:()=>import('../pages/center/groupOrder/index')
      }
    ]
  },
  {
    path: '/paySuccess',
  component:()=>import('../pages/paySuccess/index')
  },
  {
    path:'/pay',
    component:()=>import('../pages/Pay/index'),
    name:'pay',
    beforeEnter:(to,from,next)=>{
    if(from.path=='/trade'){
      next()
    }else {
      next(false)
    }
    }
  },
  {
    path: '/trade',
    component:()=>import('../pages/Trade/index'),
    name:'trade',
    beforeEnter:(to,from,next)=>{//路由独享守卫
      if(from.path=='/shopCart' || from.path=='/login'){//这个路径过来的才可以过去,不然回到以前的路径页面
        next()
        }else{
        next(false)
      }
    }
  },
  {
  path: '/shopCart',
    name:'shopCart',
    component:()=>import('../pages/shopCart/index')
  },
  {
    path: '/addCartSuccess',
    name: 'addCartSuccess',
    component:()=>import('../pages/AddCartSuccess/index'),
    meta: {isShow:true}
  },
  {
    path:'/detail/:skuid',
    component:()=>import('../pages/Details/index')
  },
  {
    path: '/login',
    meta:{show:false},
    component: () => import('../pages/login/index')
  },
  {
    path: '/register',
    meta:{show:false},
    component: () => import('../pages/register/index')
  },
  {
    path: '/home',
    meta:{show:true},
    // props:{a:1,b:2},//路由组件之间传递数据可以通过props,接收也是props
    component: () => import('../pages/home/index')
  },
  {
    path: '/search/:keyword?',//?代表参数可以传递可以不传
    name:'search',
    meta:{show:true},
    // props:($route)=>({keyword:$route.query.keyword}),
    component: () => import('../pages/search')
  }
]
